Using git in RStudio

Stephen, Jennifer, Tiago & David

Setup

  • Assume R, RStudio & git installed & working together
    • If not, see Appendix
  • Create a GitHub account
  • Create a repository (“repo”) on GitHub
  • clone the repo as an RStudio project
  • Write a README.md using markdown

Regular use

Step 1 Click “Pull” on “Git” panel

  • Create, edit, modify, e.g., R scripts, then:

Step 2 Click “Commit” on “Git” panel

Step 3 Check boxes to “Stage” changes to commit

Step 4 Write “Commit message” & click “Commit”

Step 5 Once committed, don’t forget to “Push”

  • Changes visible on GitHub 😅

Appendix

Install R on Windows

  • Visit the R website
  • Follow the links to download R, incl. select mirror and OS
  • Double click installer and follow instructions
  • Install required packages with install.packages()

R website

Install RStudio on Windows

  • Download RStudio installer
  • Double click installer and follow instructions

RStudio Desktop download page

Install git on Windows

  • Download git, currently v 2.45.2
  • Double click installer and follow instructions

Installation location

Note the location where git is installed, e.g.

C:\Users\{...}\AppData\Local\Programs\

  • At “Choose the default behaviour of git pull”: select Rebase
  • Set git configurations, e.g., user.name, user.email, etc.

Initial git installer screen

Getting them to work together

  • git authentication is OS-specific - see David’s slides
  • Connect RStudio and git: Tools > Global Options… > Git/SVN

Connect RStudio and git